package com.group.activity.controller;

import com.group.activity.entity.SeckillSkuRelationshipEntity;
import com.group.activity.service.SeckillSkuRelationshipService;
import com.group.common.utils.PageUtils;
import com.group.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Map;



/**
 * 秒杀场次和商品关联表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-11-15 09:02:32
 */
@RestController
@RequestMapping("activity/seckillskurelationship")
public class SeckillSkuRelationshipController {
    @Autowired
    private SeckillSkuRelationshipService seckillSkuRelationshipService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = seckillSkuRelationshipService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		SeckillSkuRelationshipEntity seckillSkuRelationship = seckillSkuRelationshipService.getById(id);

        return R.ok().put("seckillSkuRelationship", seckillSkuRelationship);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SeckillSkuRelationshipEntity seckillSkuRelationship){
		seckillSkuRelationshipService.save(seckillSkuRelationship);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SeckillSkuRelationshipEntity seckillSkuRelationship){
		seckillSkuRelationshipService.updateById(seckillSkuRelationship);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		seckillSkuRelationshipService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
